package com.example.mylazyviewpager;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.mylazyviewpager.base.LazyFragment5;

public class MyFragment_to_Activity extends LazyFragment5 {
    private final String TAG = "MyFragment_to_Activity";
    private Button mButton;
    private TextView mTextView;
    private int index;
    public MyFragment_to_Activity(int index) {
        super(index);
        this.index = index;
    }

    @Override
    protected void initView(View rootView) {
        Log.e(TAG, "initView: " + index);
        if (rootView != null){
            mButton = rootView.findViewById(R.id.jump);
            mButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), OtherActivity.class);
                    startActivity(intent);
                }
            });

            mTextView = rootView.findViewById(R.id.text);
        }
    }

    @Override
    protected void onFragmentLoad() {
        super.onFragmentLoad();
        Log.e(TAG, "onFragmentLoad: " + index + " 加载成功");
        mTextView.setText("加载成功");
    }

    @Override
    protected void onFragmentStopLoad() {
        super.onFragmentStopLoad();
        Log.e(TAG, "onFragmentStopLoad: " + index+" 停止加载");
    }

    @Override
    protected int getLayoutRes() {
        return R.layout.fragment_to_activity_layout;
    }
}
